package org.example.application.impl;

import org.example.application.CheckoutService;
import org.example.application.assembler.OrderDtoAssembler;
import org.example.domain.model.Order;
import org.example.domain.repository.OrderRepository;
import org.example.interfaces.command.CheckoutCommand;
import org.example.interfaces.dto.OrderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author liyishan
 * @date 2023/5/8 15:52
 * @apiNote
 */
@Service
public class CheckoutServiceImpl implements CheckoutService {
    @Autowired
    private OrderRepository orderRepository;
    @Override
    public OrderDTO checkout(CheckoutCommand cmd) {
        Order order = new Order();
        Order savedOrder = orderRepository.save(order);
        return OrderDtoAssembler.orderToDTO(savedOrder);
    }
}
